home *** CD-ROM | disk | FTP | other *** search
- property squareList, locList, squareListOccupation, computerSprites, userSprites, vicList, moveCounter, moveDimeCounter, moveThisOne, moveToThisSquare, playMode, whosNext, scoreCounter
- global autoMoveObject, sndObject
-
- on new me
- playMode = 2
- vicList = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [3, 5, 7]]
- scoreCounter = [0, 0]
- return me
- end
-
- on initGame me
- if (scoreCounter[1] + scoreCounter[2]) = 5 then
- if scoreCounter[1] > scoreCounter[2] then
- v = "p"
- else
- v = "t"
- end if
- go("out" & v)
- else
- whosNext = 0
- moveCounter = 0
- moveDimeCounter = 0
- squareList = []
- locList = []
- squareListOccupation = [0, 0, 0, 0, 0, 0, 0, 0, 0]
- computerSprites = []
- userSprites = []
- end if
- end
-
- on computerMove me
- moveCounter = moveCounter + 1
- if moveCounter < 4 then
- moveThisOne = moveCounter
- else
- moveThisOne = 0
- end if
- moveToThisSquare = 0
- if random(playMode) = 1 then
- check2onArow(me, computerSprites)
- end if
- if moveToThisSquare = 0 then
- if random(playMode) = 1 then
- check2onArow(me, userSprites)
- end if
- end if
- if moveToThisSquare = 0 then
- checkAny(me)
- end if
- repeat with n = 1 to squareList.count
- if locList[n] = sprite(computerSprites[moveThisOne]).loc then
- squareListOccupation[n] = 0
- exit repeat
- end if
- end repeat
- autoMove(autoMoveObject, sprite(computerSprites[moveThisOne]), moveToThisSquare)
- sprite(computerSprites[moveThisOne]).loc = point(moveToThisSquare[1], moveToThisSquare[2])
- updateStage()
- checkSuccess(me)
- end
-
- on success me
- case playMode of
- 0:
- if whosNext = 1 then
- v = random(2) + 2
- scoreCounter[1] = scoreCounter[1] + 1
- else
- v = random(2)
- scoreCounter[2] = scoreCounter[2] + 1
- end if
- 2:
- if whosNext = 1 then
- sndObject.respondSnd(1, 3, 1, 1)
- scoreCounter[1] = scoreCounter[1] + 1
- else
- sndObject.respondSnd(1, 1, 1, 1)
- scoreCounter[2] = scoreCounter[2] + 1
- end if
- 1:
- if whosNext = 1 then
- sndObject.respondSnd(1, 4, 1, 1)
- scoreCounter[1] = scoreCounter[1] + 1
- else
- sndObject.respondSnd(1, 2, 1, 1)
- scoreCounter[2] = scoreCounter[2] + 1
- end if
- end case
- if whosNext = 1 then
- sprite(scoreCounter[1] + 30).getUp()
- else
- sprite(scoreCounter[2] + 40).getUp()
- end if
- repeat while soundBusy(2)
- end repeat
- if whosNext = 1 then
- pSprites = userSprites
- else
- pSprites = computerSprites
- end if
- repeat with n = 1 to 3
- sprite(pSprites[n]).locZ = sprite(pSprites[n]).spriteNum + 130
- end repeat
- repeat while sprite(pSprites[3]).rotation < 360
- repeat with n = 1 to 3
- sprite(pSprites[n]).rotation = sprite(pSprites[n]).rotation + 20
- end repeat
- updateStage()
- end repeat
- repeat with b = 1 to 3
- repeat with n = 1 to 3
- sprite(pSprites[n]).memberNum = sprite(pSprites[n]).memberNum + 1
- end repeat
- updateStage()
- X = the ticks + 10
- repeat while the ticks < X
- end repeat
- repeat with n = 1 to 3
- sprite(pSprites[n]).memberNum = sprite(pSprites[n]).memberNum - 1
- end repeat
- updateStage()
- X = the ticks + 10
- repeat while the ticks < X
- end repeat
- end repeat
- repeat with n = 1 to 3
- sprite(pSprites[n]).locZ = sprite(pSprites[n]).spriteNum
- end repeat
- whosNext = 0
- repeat with n = 1 to 3
- autoMove(autoMoveObject, sprite(computerSprites[n]), sprite(computerSprites[n]).firstPos)
- end repeat
- repeat with n = 1 to 3
- autoMove(autoMoveObject, sprite(userSprites[n]), sprite(userSprites[n]).firstPos)
- end repeat
- go(1)
- end
-
- on checkSuccess me
- success = 0
- if whosNext = 1 then
- player = userSprites
- else
- player = computerSprites
- end if
- repeat with vic = 1 to 8
- spriteCount = 0
- repeat with sprites = 1 to 3
- repeat with n = 1 to 3
- if sprite(player[sprites]).loc = locList[vicList[vic][n]] then
- spriteCount = spriteCount + 1
- if spriteCount = 3 then
- exit repeat
- end if
- end if
- end repeat
- if spriteCount = 3 then
- exit repeat
- end if
- end repeat
- if spriteCount = 3 then
- success = 1
- exit repeat
- end if
- end repeat
- if success = 1 then
- success(me)
- else
- whosNext = whosNext * -1
- end if
- end
-
- on checkAny me
- if moveThisOne = 0 then
- moveThisOne = random(3)
- end if
- hit = 0
- repeat while hit = 0
- v = random(9)
- if squareListOccupation[v] = 0 then
- hit = v
- squareListOccupation[v] = 1
- exit repeat
- end if
- end repeat
- moveToThisSquare = squareList[hit]
- end
-
- on check2onArow me, pplayer
- success = 0
- player = pplayer
- repeat with vic = 1 to 8
- spriteCount = 0
- vicHits = []
- playerSpriteHits = []
- repeat with sprites = 1 to 3
- repeat with n = 1 to 3
- if sprite(player[sprites]).loc = locList[vicList[vic][n]] then
- spriteCount = spriteCount + 1
- vicHits[vicHits.count + 1] = n
- playerSpriteHits[playerSpriteHits.count + 1] = sprites
- if spriteCount = 2 then
- lastOneEmpty = 1
- repeat with H = 1 to 3
- if (H <> vicHits[1]) and (H <> vicHits[2]) then
- lastOne = H
- exit repeat
- end if
- end repeat
- if squareListOccupation[vicList[vic][lastOne]] = 1 then
- lastOneEmpty = 0
- end if
- if lastOneEmpty = 1 then
- exit repeat
- end if
- end if
- end if
- end repeat
- if (spriteCount = 2) and (lastOneEmpty = 1) then
- exit repeat
- end if
- end repeat
- if (spriteCount = 2) and (lastOneEmpty = 1) then
- success = 1
- exit repeat
- end if
- end repeat
- if success = 1 then
- if lastOneEmpty = 1 then
- moveToThisSquare = squareList[vicList[vic][lastOne]]
- squareListOccupation[vicList[vic][lastOne]] = 1
- if moveThisOne = 0 then
- repeat with n = 1 to 3
- if (n <> playerSpriteHits[1]) and (n <> playerSpriteHits[2]) then
- moveThisOne = n
- exit repeat
- end if
- end repeat
- end if
- end if
- end if
- end
-
- on reportUserMove me, pSprite, pSpriteRect, pSpriteOrigLoc
- overLap = [0, 0]
- repeat with n = 1 to squareList.count
- if intersect(pSpriteRect, squareList[n]) > rect(0, 0, 0, 0) then
- if squareListOccupation[n] = 0 then
- v = intersect(pSpriteRect, squareList[n])
- A = v[3] - v[1]
- b = v[4] - v[2]
- c = A + b
- if c > overLap[2] then
- overLap = [n, c]
- end if
- end if
- end if
- end repeat
- if overLap = [0, 0] then
- autoMove(autoMoveObject, sprite(pSprite), pSpriteOrigLoc)
- updateStage()
- else
- moveDimeCounter = moveDimeCounter + 1
- autoMove(autoMoveObject, sprite(pSprite), point(squareList[overLap[1]][1], squareList[overLap[1]][2]))
- squareListOccupation[overLap[1]] = 1
- repeat with g = 1 to squareList.count
- if pSpriteOrigLoc = locList[g] then
- squareListOccupation[g] = 0
- exit repeat
- end if
- end repeat
- updateStage()
- checkSuccess(me)
- end if
- end
-
- on reportSquare me, squareRect
- squareList[squareList.count + 1] = squareRect
- if squareList.count = 9 then
- repeat with n = 1 to 9
- locList[n] = point(squareList[n][1], squareList[n][2])
- end repeat
- end if
- end
-
- on reportComputer me, pSprite
- computerSprites[computerSprites.count + 1] = pSprite
- end
-
- on reportUser me, pSprite
- userSprites[userSprites.count + 1] = pSprite
- end
-